a = ''
s = ''
s1 = ''
k = 0
a = input('Введите скобочную последовательность')
for i in range(len(a)):
    if a[i] in '(){}[]<>':
        s += a[i]
for i in range(len(s)):
    if s[i] in '({[<':
        s1 += s[i]
    elif s[i] == ')' and len(s1) > 0 and s1[-1] == '(':
        s1 = s1[:-1]
    elif s[i] == ']' and len(s1) > 0 and s1[-1] == '[':
        s1 = s1[:-1]
    elif s[i] == '}' and len(s1) > 0 and s1[-1] == '{':
        s1 = s1[:-1]
    elif s[i] == '>' and len(s1) > 0 and s1[-1] == '<':
        s1 = s1[:-1]
    else:
        k += 1
        break
if s1 == '' and k == 0:
    print('True')
else:
    print('False')